cmake_minimum_required(VERSION 3.0.2)
project(ros_car)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  serial
  message_generation
)

add_compile_options(-std=c++11)

add_message_files(
  FILES
  VCU_frame.msg
  car_status_frame.msg
)

add_service_files(
  FILES
  map_plan.srv
)

generate_messages(
  DEPENDENCIES
  std_msgs
)

catkin_package(
  CATKIN_DEPENDS
  roscpp
  std_msgs
  message_runtime
)

include_directories(
  include
  include/ros_can
  include/ros_control
  include/ros_serial
  ${catkin_INCLUDE_DIRS}
)

link_directories(
  ${catkin_LIB_DIRS}
  lib/
)

add_executable( talker_CAN
                src/ROS_CAN/talker_CAN.cpp
                src/ROS_CONTROL/ros_control_driver.cpp)
target_link_libraries(talker_CAN ${catkin_LIBRARIES})
add_dependencies(talker_CAN ros_car_generate_messages_cpp)

add_executable( listener_CAN
                src/ROS_CAN/listener_CAN.cpp)
target_link_libraries(listener_CAN ${catkin_LIBRARIES})
add_dependencies(listener_CAN ros_car_generate_messages_cpp)

add_executable( ROS_CAN_LC
                src/ROS_CAN/ROS_CAN_LC.cpp
                src/ROS_CAN/ros_can_driver.cpp)
target_link_libraries(ROS_CAN_LC ${catkin_LIBRARIES} CanCmd.so)
add_dependencies(ROS_CAN_LC ros_car_generate_messages_cpp)

add_executable( ROS_CAN_EMUC
                src/ROS_CAN/ROS_CAN_EMUC.cpp)
target_link_libraries(ROS_CAN_EMUC ${catkin_LIBRARIES} Emuc64.a)
add_dependencies(ROS_CAN_EMUC ros_car_generate_messages_cpp)

add_executable( ROS_serial
                src/ROS_SERIAL/ROS_serial.cpp
                src/ROS_SERIAL/ros_serial_driver.cpp)
target_link_libraries(ROS_serial ${catkin_LIBRARIES})
add_dependencies(ROS_serial ros_car_generate_messages_cpp)

add_executable( listener_serial
                src/ROS_SERIAL/listener_serial.cpp
                src/ROS_SERIAL/ros_serial_driver.cpp)
target_link_libraries(listener_serial ${catkin_LIBRARIES})
add_dependencies(listener_serial ros_car_generate_messages_cpp)

add_executable( ROS_control 
                src/ROS_SERIAL/ros_serial_driver.cpp
                src/ROS_CONTROL/ROS_control.cpp
                src/ROS_CONTROL/ros_control_driver.cpp
                src/ROS_CONTROL/car_pid.cpp)
target_link_libraries(ROS_control ${catkin_LIBRARIES})
add_dependencies(ROS_control ros_car_generate_messages_cpp)

add_executable( ROS_map_plan 
                src/ROS_CONTROL/ROS_map_plan.cpp
                src/ROS_SERIAL/ros_serial_driver.cpp
                src/ROS_CONTROL/ros_control_driver.cpp)
target_link_libraries(ROS_map_plan ${catkin_LIBRARIES})
add_dependencies(ROS_map_plan ros_car_generate_messages_cpp)